#include "MultiMedia.h"
#include <iostream>
#include <string>
#include <sstream>
#include <istream>

using namespace std;


MultiMedia::MultiMedia(void)
{
	title = " ";
	author = " ";
	publisher = " ";
	year = 0;
	price = 0;
}

MultiMedia::MultiMedia(string title, string author, string publisher, int year, int price)
{
	this ->title = title;
	this ->author = author;
	this ->publisher = publisher;
	this ->year = year;
	this ->price = price;
}

void MultiMedia::ReadFromConsole()
{
	cout << "Author? " << "\n";
	getline(cin, author);
	cout << "Title? " << "\n";
	getline(cin, title);
	cout << "Publisher? " << "\n";
	getline(cin, publisher);
	cout << "Year published?" << "\n";
	cin >> year;
	cout << "Price? " << "\n";
	cin >> price;
}

void MultiMedia::WriteToConsole()
{
	cout << title << ", by " << author << "\n";
	cout << "Published by " << publisher << " in " << year << "\n";
	cout << price << " kronor \n";
}

ostream &operator <<(ostream &out, MultiMedia &multi)
{
	out << '"' << multi.title << '"' << ", " << multi.author << ", " << multi.publisher << ", " << multi.year << ", " << multi.price << endl;
	return out;
}

istream &operator >>(istream &in, MultiMedia &multi)
{
	char c;
	getline(in, multi.title, ',');
	getline(in, multi.author, ',');
	getline(in, multi.publisher, ',');
	in >> skipws >> multi.year >> skipws >> c;
	in >> skipws >> multi.price;
	return in;
}

string MultiMedia::GetTitle(){ return title;}
void MultiMedia::SetTitle(string title){ this -> title = title;}
string MultiMedia::GetAuthor(){return author;}
void MultiMedia::SetAuthor(string author){this -> author = author;}
string MultiMedia::GetPublisher(){return publisher;}
void MultiMedia::SetPublisher(string publisher){this -> publisher = publisher;}
int MultiMedia::GetYear(){return year;}
void MultiMedia::SetYear(int year){this -> year = year;}
int MultiMedia::GetPrice(){return price;}
void MultiMedia::SetPrice(int price){this -> price = price;}


